package Terminal.View;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.swing.BorderFactory;
import javax.swing.JLabel;

import Terminal.Entity.Dominio.ETask;

public class JPannelloDescrizioneTask extends JPannelloDatiTask{

		private ETask task;
		private JLabel tasktitololabel;
		private JLabel tasktitolotextlabel;
		private JLabel taskidlabel;
		private JLabel taskidtextlabel;
		private JLabel taskiniziolabel;
		private JLabel taskiniziotextlabel;
		private JLabel taskscadenzalabel;
		private JLabel taskscadenzatextlabel;
		private JLabel taskstatolabel;
		private JLabel taskstatotextlabel;
		private JLabel taskconsulentelabel;
		private JLabel taskconsulentetext;
		private JLabel taskcostoorariolabel;
		private JLabel taskcostoorariotextlabel;
		private JLabel taskcostototalelabel;
		private JLabel taskcostototaletextlabel;
		private int size_font_title=18;
		private int size_font_values=16;
	
		public JPannelloDescrizioneTask(){
			super();
			createComponents();
		}

		protected void createComponents() {
			
			this.setLayout(null);
			this.setBackground(Color.white);
			
	        /*title= BorderFactory.createTitledBorder("Descrizione progetto");
	        this.setBorder(title);*/
			////////////////////////////////////PANNELLO DI DESCRIZIONE////////////////////////////////////
			       
	      

	        
			tasktitololabel = new JLabel("Titolo:");
			tasktitololabel.setLocation(20,20);//40,0);
			tasktitololabel.setPreferredSize(new Dimension(200,50));
			tasktitololabel.setSize(tasktitololabel.getPreferredSize());
			tasktitololabel.setFont(new Font(tasktitololabel.getFont().getName(), Font.BOLD, size_font_title));
			this.add(tasktitololabel);
			
			
			
	        
	        tasktitolotextlabel = new JLabel();
	        tasktitolotextlabel.setLocation(220, 20);//200,tasktitololabel.getLocation().y);
			tasktitolotextlabel.setPreferredSize(new Dimension(200, 50));
			tasktitolotextlabel.setSize(tasktitolotextlabel.getPreferredSize());
			this.add(tasktitolotextlabel);
			
			tasktitolotextlabel.setFont(new Font(tasktitolotextlabel.getFont().getFontName(), Font.ITALIC,size_font_values));
			
			
			
			taskidlabel = new JLabel("Identificatore:");
			//taskidlabel.setLocation(50, tasktitololabel.getLocation().y+tasktitololabel.getPreferredSize().height);
			taskidlabel.setLocation(20,70);//40,40);
			taskidlabel.setPreferredSize(new Dimension(200,50));
			taskidlabel.setSize(taskidlabel.getPreferredSize());
			taskidlabel.setFont(new Font(taskidlabel.getFont().getName(), Font.BOLD, size_font_title));
			this.add(taskidlabel);
	       
	        
	        
	       
			taskidtextlabel= new JLabel();
			taskidtextlabel.setLocation(220,77);//200,taskidlabel.getLocation().y);
			taskidtextlabel.setPreferredSize(new Dimension(200, 50));
			taskidtextlabel.setSize(taskidtextlabel.getPreferredSize());
			this.add(taskidtextlabel);
			
			taskidtextlabel.setFont(new Font(taskidtextlabel.getFont().getFontName(), Font.ITALIC,size_font_values));

			
			taskiniziolabel = new JLabel("Data di inizio:");
			//taskiniziolabel.setLocation(50, taskidlabel.getLocation().y+taskidlabel.getPreferredSize().height);
			taskiniziolabel.setLocation(20,120);//40,80);
			taskiniziolabel.setPreferredSize(new Dimension(200, 50));
			taskiniziolabel.setSize(taskiniziolabel.getPreferredSize());
			taskiniziolabel.setFont(new Font(taskiniziolabel.getFont().getName(), Font.BOLD, size_font_title));
			this.add(taskiniziolabel);
	        
			taskiniziotextlabel = new JLabel();
			taskiniziotextlabel.setLocation(220,127);//200,taskiniziolabel.getLocation().y);
			//taskiniziotextlabel.setLocation(220,110);
			taskiniziotextlabel.setPreferredSize(new Dimension(200, 50));
			taskiniziotextlabel.setSize(taskiniziotextlabel.getPreferredSize());
			this.add(taskiniziotextlabel);
			taskiniziotextlabel.setFont(new Font(taskiniziotextlabel.getFont().getFontName(), Font.ITALIC,size_font_values));
		
			taskscadenzalabel = new JLabel("Data di Fine:");
			taskscadenzalabel.setLocation(20,170);//40,120);
			taskscadenzalabel.setPreferredSize(new Dimension(200,50));
			taskscadenzalabel.setSize(taskscadenzalabel.getPreferredSize());
			taskscadenzalabel.setFont(new Font(taskscadenzalabel.getFont().getName(), Font.BOLD, size_font_title));
			this.add(taskscadenzalabel);
			
	        
	        taskscadenzatextlabel = new JLabel();
	        taskscadenzatextlabel.setLocation(220,taskscadenzalabel.getLocation().y);//200,taskscadenzalabel.getLocation().y);
	        taskscadenzatextlabel.setPreferredSize(new Dimension(150, 50));
			taskscadenzatextlabel.setSize(taskscadenzatextlabel.getPreferredSize());
			this.add(taskscadenzatextlabel);
			
			taskscadenzatextlabel.setFont(new Font(taskscadenzatextlabel.getFont().getFontName(), Font.ITALIC,size_font_values));
			
			
			taskstatolabel = new JLabel("Stato:");
			taskstatolabel.setLocation(20,220);//40,160);
			taskstatolabel.setPreferredSize(new Dimension(200,50));
			taskstatolabel.setSize(taskstatolabel.getPreferredSize());	
			taskstatolabel.setFont(new Font(taskstatolabel.getFont().getFontName(), Font.BOLD,size_font_title));
			this.add(taskstatolabel);
			
	        
	        taskstatotextlabel = new JLabel();
	        taskstatotextlabel.setLocation(220,taskstatolabel.getLocation().y);//200,taskstatolabel.getLocation().y);
	        taskstatotextlabel.setPreferredSize(new Dimension(200, 35));//50));
			taskstatotextlabel.setSize(taskstatotextlabel.getPreferredSize());
			//taskstatotextlabel.setFont(new Font(taskstatotextlabel.getFont().getName(), Font.BOLD, size_font_title));
			this.add(taskstatotextlabel);
					
			taskstatotextlabel.setFont(new Font(taskstatotextlabel.getFont().getFontName(), Font.ITALIC,size_font_values));
			
			
			taskconsulentelabel = new JLabel("Consulente:");
			//taskconsulentelabel.setLocation(40,160);
			taskconsulentelabel.setLocation(20,270);//40,200);
			taskconsulentelabel.setPreferredSize(new Dimension(200,35));//50));
			taskconsulentelabel.setSize(taskconsulentelabel.getPreferredSize());
			taskconsulentelabel.setFont(new Font(taskconsulentelabel.getFont().getName(), Font.BOLD, size_font_title));
			this.add(taskconsulentelabel);
	        
	        taskconsulentetext = new JLabel();
	       
	        taskconsulentetext.setLocation(220,taskconsulentelabel.getLocation().y);//200,taskconsulentelabel.getLocation().y);
	        //taskconsulentetext.setLocation(220,210);
	        taskconsulentetext.setPreferredSize(new Dimension(200, 35));//50));
	        taskconsulentetext.setSize(taskconsulentetext.getPreferredSize());
	        taskconsulentetext.setFont(new Font(taskconsulentetext.getFont().getName(), Font.ITALIC, size_font_values));
			this.add(taskconsulentetext);
			
			

			
			
		//	visualizzaElemento(task);
			
//			super.setSize(taskscadenzatextlabel.getLocation().x+100,taskconsulentetext.getLocation().y+taskconsulentetext.getSize().height);
			
			//this.setBounds(370, 80, 700, 350);
			setBounds(400,231,550,350);
			setBorder(BorderFactory.createLineBorder(Color.GRAY));
			
		}
		
		
		public void visualizzaElemento(ETask task) {
			//this.task = task;
			if(task!=null)
			{
				
			Format dataformat= new SimpleDateFormat("dd/MM/yyyy");
			tasktitolotextlabel.setText(task.getTitolo());
			taskidtextlabel.setText(task.getId()+"");		
			try{
				if(task.getDataInizio()!=null) 	
				{
					Date datetemp= task.getDataInizio();
					taskiniziotextlabel.setText(dataformat.format(datetemp));
				}
				else 
						taskiniziotextlabel.setText("  "); 
			}catch (Exception e) 
				{	
					taskiniziotextlabel.setText("  ");		
					}
			
			try{
				if(task.getDataFine()!=null)
					{
					Date datetemp= task.getDataFine();
					taskscadenzatextlabel.setText(dataformat.format(datetemp));
					}
				else taskscadenzatextlabel.setText(" ");
				}catch (Exception e) 	
				{
					taskscadenzatextlabel.setText(" ");	
					}
			if(task.getConsulenteAttuale()!=null)	
			{
				System.out.println(task.getConsulenteAttuale().getCognome());
				taskconsulentetext.setText(task.getConsulenteAttuale().getCognome()+" "+task.getConsulenteAttuale().getNome()+" matricola: "+task.getConsulenteAttuale().getMatricola());
			}
			else taskconsulentetext.setText("  ");
			
			if(task.getStatoObj()!=null) 
			{
				taskstatotextlabel.setText(task.getStatoObj().getStatoString());
			}
			
			else  
				taskstatotextlabel.setText(" ");
			
			
			
			
			}
		}
	
}
